<link rel="stylesheet" href="/ceca_two/css/costShareOne.css" />
<!--header-->
<style type="text/css">
	.moneyInp{border: none;}
</style>
<!--# include virtual="/ceca_two/common/html/header.html"-->
<!--# include virtual="/ceca_two/modules/costnorm/base/costShare.html"-->	
		<h1 class="shareName">每平方米建筑面积主要工料指标</h1>
		<div class="explain">填写说明：以下内容均为必填项，若本项目无此项内容请填写“无”。</div>
		<table class="shareTable">
			<tr>
				<td>序号</td>
				<td>项目名称</td>
				<td>单位</td>
				<td>平方米用量</td>
				<td style="color: #fff;">金额（元）</td>
			</tr>
			<tr>
				<td>1</td>
				<td>工日</td>
				<td>天</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
			<tr>
				<td>2</td>
				<td>混凝土</td>
				<td>㎡</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
			<tr>
				<td>3</td>
				<td>钢筋</td>
				<td>kg</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
			<tr>
				<td>4</td>
				<td>防水卷材</td>
				<td>㎡</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
			<tr>
				<td>5</td>
				<td>防水涂料</td>
				<td>kg</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
			<tr>
				<td>6</td>
				<td>混凝土切块</td>
				<td>㎡</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
			<tr>
				<td>7</td>
				<td>钢结构构件</td>
				<td>t</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
			<tr>
				<td>8</td>
				<td>机械费</td>
				<td>元</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
			<tr>
				<td>9</td>
				<td>模板租赁费</td>
				<td>元</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
			<tr>
				<td>10</td>
				<td>脚手架租赁费</td>
				<td>元</td>
				<td><input type="text" name="" id="" value="" class="inp"/></td>
				<td><input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" / class="moneyInp"></td>
			</tr>
		</table>
		<div class="shareCostBtn">
			<div class="saveBtn">
				<a href="">保存</a>
			</div>
			<div class="nextBtn" id="prevBtn">
				<a>上一步</a>
			</div>
			<div class="nextBtn" id="nextBtn">
				<a>下一步</a>
			</div>
		</div>
	</div>
</div>
<script>
layui.use(['costshareOne'], function(){

//	$("#nextBtn").on("click",function (){
//		window.location.href = "/ceca_two/modules/share/Industry/fifth.html"+window.location.search;
//	})
	
});
</script>
<!--底部-->
<!--# include virtual="/ceca_two/common/html/footer.html"-->
</body>
</html>
<script>
layui.use(['costshareOne'], function(){
	
var costId = GetQueryString("costId");
var catalogId = GetQueryString("catalogId");

function GetQueryString(name){
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}

	$("#prevBtn").on('click',function (){
		window.location.href = "/ceca_two/modules/share/IndystryThree/three.html"+window.location.search;
	})

	$("#nextBtn").on("click",function (){
		
		var data = saveData();

		$.ajax({
			type:"post",
			url:"/guidance_service/front/costIndex/update.do",
			data:{
				costId : costId,
				perSquareQuantity: data
			},
			success:function (result){
				console.log(result)
				window.location.href = "/ceca_two/modules/share/shareSubmit.html"+window.location.search;
			},error:function (){
				layer.msg("请求错误！请稍候重试",{icon:2,time:3000});
			}
		});
	})
});


setInterval(function (){
	sessionStorage.setItem("civilFour", saveData());
},3000)

if (sessionStorage.getItem('civilFour')) {
	var data = JSON.parse(sessionStorage.getItem('civilFour'));
	
	for (i = 0 ; i < data.length ; i++) {
	console.log(data[i])
			$(".shareTable").find("tr").eq(i+1).find("input").eq(0).val(data[i].dosage);
			$(".shareTable").find("tr").eq(i+1).find("input").eq(1).val(data[i].money);
		
	}
	
}



function saveData(){
	var arr = [];
	
	for (i = 1 ; i < $(".shareTable tr").length ; i++) {

		arr.push({
			name : $(".shareTable tr").eq(i).find("td").eq(1).html(),
			unit : $(".shareTable tr").eq(i).find("td").eq(2).html(),
			dosage : $(".shareTable tr").eq(i).find("td").eq(3).find("input").val(),
			money : $(".shareTable tr").eq(i).find("td").eq(4).find("input").val()

		})
	}

	return	arr = JSON.stringify(arr);
}

</script>
